<?php
require S_ROOT . 'source/newjpush/autoload.php';

require_once(S_ROOT."source/newjpush/src/JPush/Client.php");

$device = array('android','ios');

//$app_key = JIGUANGAPPKEY;
//$master_secret = JIGUANGMASTERSECRET;
//特惠
$app_key = '9c2e23f4ab90952aea3ac083';
$master_secret = '98db1ef36e56f4c46bd6764e';
//爱打折
//$app_key = '0ca71dd1e25c381e137e3e9e';
//$master_secret = '4ec9d804659b04b8173f1ed0';
$client = new Client($app_key, $master_secret);

$device = 'ios';
$uids = array('216000');
$content = '测试';
$pttype['pt'] = '2';
try {
	$result = $client->push();
	$result->setPlatform($device);
	$result->addAlias($uids);
	$result->setNotificationAlert($content);
	if ($pttype['pt'] == 1) {
		$result->androidNotification($content, array('title' => '爱打折', 'builder_id' => 1, 'extras' => array()));
	} else {
		$result->iosNotification($content, array('sound' => 'sound', 'badge' => '+1', 'content-available' => null, 'mutable-content' => null, 'category' => null, 'extras' => array()));
	}
	$result->setOptions(100000, 86400, null, false);
	$result->send();
} catch (Exception $e) {
	echojson('操作成功', 1, $datas);
}



 function objtoarray1($obj) {
	if (is_object ( $obj )) {
		$obj = ( array ) $obj;
	}
	if ($obj)
		foreach ( $obj as $k => $o ) {
			if (is_object ( $o ) || is_array ( $o )) {
				$obj [$k] = objtoarray ( $o );
			}
		}
	return $obj;
}
